<?php
Yii::app()->clientScript->registerScriptFile($this->staticsPath."/js/fingerprint.js",CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScriptFile($this->staticsPath."/js/jquery-1.10.1.min.js",CClientScript::POS_HEAD);
//Yii::app()->clientScript->registerScriptFile($this->staticsPath."/js/alert.js",CClientScript::POS_HEAD);


Yii::app()->clientScript->registerScriptFile($this->staticsPath."/frontend/mobiscroll/js/mobiscroll.core.js",CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScriptFile($this->staticsPath."/frontend/mobiscroll/js/mobiscroll.widget.js",CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScriptFile($this->staticsPath."/frontend/mobiscroll/js/mobiscroll.scroller.js",CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScriptFile($this->staticsPath."/frontend/mobiscroll/js/mobiscroll.util.datetime.js",CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScriptFile($this->staticsPath."/frontend/mobiscroll/js/mobiscroll.datetimebase.js",CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScriptFile($this->staticsPath."/frontend/mobiscroll/js/mobiscroll.widget.ios.js",CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScriptFile($this->staticsPath."/frontend/mobiscroll/js/mobiscroll.i18n.zh.js",CClientScript::POS_HEAD);




Yii::app()->clientScript->registerCssFile($this->staticsPath."/css/global.css");
Yii::app()->clientScript->registerCssFile($this->staticsPath."/css/index.css");
Yii::app()->clientScript->registerCssFile($this->staticsPath."/css/font-awesome.min.css");

Yii::app()->clientScript->registerCssFile($this->staticsPath."/frontend/css/bootstrap.min.css");
Yii::app()->clientScript->registerCssFile($this->staticsPath."/frontend/mobiscroll/css/mobiscroll.animation.css");
Yii::app()->clientScript->registerCssFile($this->staticsPath."/frontend/mobiscroll/css/mobiscroll.widget.css");
Yii::app()->clientScript->registerCssFile($this->staticsPath."/frontend/mobiscroll/css/mobiscroll.widget.ios.css");
Yii::app()->clientScript->registerCssFile($this->staticsPath."/frontend/mobiscroll/css/mobiscroll.scroller.css");
Yii::app()->clientScript->registerCssFile($this->staticsPath."/frontend/mobiscroll/css/mobiscroll.scroller.ios.css");
Yii::app()->clientScript->registerScriptFile($this->staticsPath."/js/alert.js",CClientScript::POS_HEAD);


?>
<style>
    .form-control {
        background-color: #fff;
        background-image: none;
        border: 1px solid #ccc;
        border-radius: 4px;
        box-shadow: 0 1px 1px rgba(0, 0, 0, 0.075) inset;
        color: #555;
        font-size: 14px;
        height: 34px;
        line-height: 1.42857;
        padding: 6px 12px;
        transition: border-color 0.15s ease-in-out 0s, box-shadow 0.15s ease-in-out 0s;
        width: 86%;
        display: inline-block;
    }
    .fa{
        width: 36px;
    }
</style>
<header class="homeHder header">
    <a href="<?php echo Yii::app()->createUrl('index/index',array('openid'=>$openid)) ?>">
        <div class="hder_return flol">
            <i class="size fa fa-angle-left"></i>
        </div>
    </a>
    <div class="hder_logo">家长注册</div>
</header>
<section class="cont_wrpa pdX10">

    <div class="modl_tel">
        <i class="fa fa-user"></i>
        <input id="user_name" type="text" placeholder="姓名">
    </div>
    <div class="modl_tel">
        <i class="fa fa-graduation-cap"></i>
        <input id="cusername" type="text" placeholder="学生姓名">
    </div>
    <div class="modl_tel">
        <i class="fa fa-barcode"></i>
        <input id="code_num" type="text" placeholder="学籍号">
    </div>



    <div class="modl_tel">
        <i class="fa fa-lock"></i>
        <input id="passwd" type="password" placeholder="密码">
    </div>
    <div class="modl_tel">
        <i class="fa fa-refresh"></i>
        <input id="repasswd" type="password" placeholder="确认密码">
    </div>
    <div class="modl_tel">
        <i class="fa fa-venus-mars"></i>
        <select class="form-control" id="sex" name="sex">
            <option selected="selected" value="1">男</option>
            <option value="2">女</option>
        </select>

    </div>

    <div class="modl_tel">
        <i class="fa fa-chain"></i>
        <input id="is_relation" type="text" placeholder="关系">
    </div>

    <div class="modl_tel">
        <i class="fa fa-mobile"></i>
        <input id="user_phone" type="text" placeholder="电话">
    </div>



    <div class="go">
        <a id="login" href="javascript:void(0);">立即注册</a>
    </div>

</section>
<br><br><br>
<script>
    $(function(){
        $("#gid").change(function() {
            loadClass($("#gid").val());
        });
        function loadClass(gid) {
            $.ajax({
                url: '<?php echo Yii::app()->createAbsoluteUrl("index/loadClass"); ?>'+ 'gid/' +gid,
                type: 'POST',
                dataType: 'html',
                success: function(msg) {
                    $("#cid").html(msg);
                }
            });
        }


        $("#login").click(function(){
            var _this = $(this);
            var user_name = $("#user_name").val();
            var cusername = $("#cusername").val();



            var passwd = $("#passwd").val();
            var repasswd = $("#repasswd").val();
            var code_num = $("#code_num").val();
            var is_relation = $("#is_relation").val();
            var user_phone = $("#user_phone").val();
            var sex = $("#sex").val();
            if(user_name ==''){
                alert('姓名不得为空');
                return false;
            }
            if(user_name.length < 2){
                alert('姓名不得小于2位');
                return false;
            }
            if(user_name.length > 30){
                alert('姓名不得大于30位');
                return false;
            }
            if(cusername ==''){
                alert('学生姓名不得为空');
                return false;
            }

            if(code_num ==''){
                alert('学生学籍号不得为空');
                return false;
            }

            if(passwd ==''){
                alert('密码不得为空');
                return false;
            }
            if(passwd.length > 20){
                alert('密码不得大于20位');
                return false;
            }
            if(passwd != repasswd){
                alert('两次密码不一致');
                return false;
            }
            if(is_relation ==''){
                alert('关系不得为空');
                return false;
            }
            if(user_phone ==''){
                alert('电话不得为空');
                return false;
            }
            if (!is_mobile(user_phone)) {
                alert("请输入正确的电话号码");
                return false;
            }
            function is_mobile(v) {
                var mobile = /^1[3|5|7|8]\d{9}$/;
                return mobile.test(v);
            }
            $.ajax({
                type: "POST",
                url: '<?php echo Yii::app()->createUrl('index/ajaxRegister') ?>',
                data: {
                    user_name:user_name,
                    cusername:cusername,
                    passwd:passwd,
                    repasswd:repasswd,
                    code_num:code_num,
                    is_relation:is_relation,
                    user_phone:user_phone,
                    sex:sex,
                    type:'<?php echo $key; ?>',
                    lx:2,
                    openid:'<?php echo $openid; ?>',
                    image:'<?php echo $user['headimgurl'] ?>',
                },
                dataType: "json",
                beforeSend: function () {
                    _this.css('background','#ccc');
                    _this.html('<i class="fa fa-circle-o-notch fa-spin"></i>&nbsp;&nbsp;正在注册中');
                },
                success: function (data) {
                    if (data) {
                        if (data['status'] == 1) {
                            localStorage["stroeUser"] = data['key'];
                            <?php if($openid){ ?>
                            window.location.href='<?php echo Yii::app()->createUrl('index/list1',array('openid'=>$openid)) ?>';
                            <?php }else{ ?>
                            window.location.href='<?php echo Yii::app()->createUrl('index/list1') ?>';
                            <?php } ?>
                        } else {
                            alert(data['message']);
                            _this.css('background','#68c8c7');
                            _this.html('立即注册');
                            return false;
                        }
                    }
                }
            });
        });


    })
</script>

<script type="text/javascript">
    $(function () {
        var nowData=new Date();
        var opt= {
            theme:'ios', //设置显示主题
            mode:'scroller', //设置日期选择方式，这里用滚动
            display:'bottom', //设置控件出现方式及样式
            preset : 'date', //日期:年 月 日 时 分

            maxDate:new Date(nowData.getFullYear(),nowData.getMonth()+2,nowData.getDate()+7,23),
//            maxDate:new Date(nowData.getFullYear(),nowData.getMonth()+2,nowData.getDate()+7,22,00),
//              dateFormat: 'yy-mm-dd', // 日期格式
//              dateOrder: 'yymmdd', //面板中日期排列格式
            stepMinute: 10, //设置分钟步长
            yearText:'年',
            monthText:'月',
            dayText:'日',
            hourText:'时',
            minuteText:'分',
            lang:'zh' //设置控件语言};
        };
        $('#birthday').mobiscroll(opt);
        $('#start_time').mobiscroll(opt);

    });
</script>

